package cn.sycoder.resp;


import lombok.Data;

@Data
//@Builder
public class Resp {

    private int code;
    private String msg;
    private Object data;
    private boolean success; // 执行成功

    public Resp() {
    }

    public Resp(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public Resp(boolean successInfo, Object data) {
        this.success = successInfo;
        this.data = data;
    }

    public Resp(boolean successInfo) {
        this.success = successInfo;
    }

    public Resp(Integer code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    // 查询成功返回状态码及物品信息
    public static Resp success(Integer code,Object data){
        return new Resp(code,data);
    }

    // 执行成功，返回结果
    public static Resp success(boolean successInfo,Object data){
        return new Resp(successInfo,data);
    }

    // 执行成功，返回true
    public static Resp success(boolean successInfo){
        return new Resp(successInfo);
    }

    // 执行失败，返回msg
    public static Resp success(boolean successInfo,String msg){
        return new Resp(successInfo,msg);
    }
}
